// pages/linpai/help-orderDetail.js
Page({

    /**
     * 页面的初始数据
     */
    data: {

    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {
        console.log(options)
        this.loadData(options.id);
    },

    loadData(id) {
        getApp().http.post('rest/plate-number-order/view?id=' + id).then(res => {
            res.content.information && (res.content.information = JSON.parse(res.content.information));
            this.setData({
                content: res.content
            })
        })
    },

    pre(e) {
        wx.previewImage({
            urls: this.data.content.information,
            current: e.target.dataset.index,
        })
    },
    refuseTap() {
        wx.showModal({
            title: '提示',
            content: '确定拒绝这笔订单吗？',
            success: res => {
                wx.showLoading({
                    title: '',
                })
                const url = `rest/plate-number-order/update-status?id=${this.data.content.id}&status=已拒绝`
                res.confirm && getApp().http.post(url, {
                    showMsg: false
                }).then(res => {
                    wx.hideLoading()
                    this.loadData(this.data.content.id);
                    wx.showToast({
                        title: '保存成功',
                    })
                })
            }
        })
    },
    okTap() {
        wx.showLoading({
            title: '',
        })
        const url = `rest/plate-number-order/update-status?id=${this.data.content.id}&status=已完成`
        getApp().http.post(url).then(res => {
            wx.hideLoading();
            this.loadData(this.data.content.id);
            wx.showToast({
                title: '保存成功',
            })
        })
    },
})